package ynu.edu.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ynu.edu.entity.Food;
import ynu.edu.repository.FoodRepository;

import java.util.List;

@Service
public class FoodService {

    @Autowired
    private FoodRepository foodRepository;

    public List<Food> listFoodByBusinessId(Integer businessId) {
        return foodRepository.findByBusinessId(businessId);
    }

    public Food getFoodById(Integer foodId) {
        return foodRepository.findById(foodId)
                .orElseThrow(() -> new RuntimeException("食品不存在"));
    }
} 